﻿using System;
using System.IO;

namespace DarcRogue
{
    public enum TileType
    {
        Wall = 1,
        Floor
    }
    public class Tile
    {
        char chr;
        ConsoleColor color;
        string description = "";
        string name = "";
        bool solid;

        public Tile(char c, ConsoleColor co, string desc, bool solid, string name)
        {
            chr = c;
            color = co;
            description = desc;
            this.solid = solid;
            this.name = name;
        }
        public Tile(string file)
        {
            FileStream fs = new FileStream(file, FileMode.Open);
            BinaryReader br = new BinaryReader(fs);
            chr = br.ReadChar();
            color = (ConsoleColor)br.ReadInt32();
            description = br.ReadString();
            name = br.ReadString();
            solid = br.ReadBoolean();
            br.Close();
        }

        public void Draw()
        {
            Console.ForegroundColor = color;
            Console.Write(chr);
            Console.ForegroundColor = ConsoleColor.Gray;
        }

        public void Save(string s)
        {
            FileStream fs = new FileStream(s, FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);
            bw.Write(chr);
            bw.Write((int)color);
            bw.Write(description);
            bw.Write(name);
            bw.Write(solid);
            bw.Close();
        }

        public string Description { get { return description; } }
        public bool Solid { get { return solid; } }
    }
}
